﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using SnippetBox.Core.Common.Extensions;
using SnippetBox.Core.Common.Paging;
using SnippetBox.Core.Data.Models;

namespace SnippetBox.Web.Models {
    public class UserProfileModel {
        public User User { get; set; }
        public IPagedList<Snippet> MySnippets { get; set; }
        public IPagedList<Snippet> MyFavorites { get; set; }

        public bool HasTwitterLink { get { return !User.TwitterUsername.IsNullOrEmpty(); } }
        public bool HasWebsiteLink { get { return !User.Website.IsNullOrEmpty() && User.Website.StartsWith("http"); } }
        public string TwitterUrl { get { return "http://twitter.com/#!/" + User.TwitterUsername; } }
        public bool IsMyProfile { get { return HttpContext.Current.Request.IsAuthenticated && User.Username == HttpContext.Current.User.Identity.Name; } }
        
        public UserProfileModel() {}
        public UserProfileModel(User user) {
            User = user;
        }
    }
}